/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.supinfo.youfood.web.servlet.admin.produit;

import com.supinfo.youfood.entity.CategorieProduit;
import com.supinfo.youfood.entity.Employe;
import com.supinfo.youfood.service.CategorieProduitService;
import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author TaKeO
 */
@WebServlet(name = "ListCategorieProduit", urlPatterns = {"/admin/liste-categories-produits"})
public class ListCategorieProduitServlet extends HttpServlet {
    
    @EJB
    private CategorieProduitService categorieProduitService;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        Employe employe = (Employe) request.getSession().getAttribute("currentEmp");
        if(employe.getType_employe().getDroits() < 700) 
        {
            request.setAttribute("isAdmin", false);
        }
        else request.setAttribute("isAdmin", true);
        
        List<CategorieProduit> categories = categorieProduitService.getAllCategorieProduit();
        request.setAttribute("categories", categories);
        
        request.getRequestDispatcher("/jsp/admin/liste-categories-produits.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        
    }

}
